package yanglib.application.metadata;

import yanglib.application.metadata.client.MetadataClient;
import yanglib.application.metadata.server.MetadataServer;

import java.nio.ByteBuffer;

/**
 * Created with IntelliJ IDEA.
 * User: user
 * Date: 9/9/14
 * Time: 9:18 PM
 * To change this template use File | Settings | File Templates.
 */
public class Test {

    public static void main(String[] args) throws Exception{
        MetadataServer server1 = new MetadataServer(2, "D:\\project-of-yang\\library\\config.xml", "D:\\project-of-yang\\library");
        MetadataServer server2 = new MetadataServer(3, "D:\\project-of-yang\\library\\config.xml", "D:\\project-of-yang\\library");
        MetadataClient client = new MetadataClient(0,  "D:\\project-of-yang\\library\\config.xml");
        long key1 = 1;
        long value1 = 1234;
        byte[] keyBytes1 = new byte[8];
        byte[] valueBytes1 = new byte[8];
        ByteBuffer tmp = ByteBuffer.wrap(keyBytes1);
        tmp.putLong(key1);
        tmp = ByteBuffer.wrap(valueBytes1);
        tmp.putLong(value1);
        long key2 = 2;
        long value2 = 4567;
        byte[] keyBytes2 = new byte[8];
        byte[] valueBytes2 = new byte[8];
        tmp = ByteBuffer.wrap(keyBytes2);
        tmp.putLong(key2);
        tmp = ByteBuffer.wrap(valueBytes2);
        tmp.putLong(value2);
        client.put(keyBytes1, valueBytes1);
        client.put(keyBytes2, valueBytes2);
        client.get(keyBytes1);
        client.get(keyBytes2);
        Thread.sleep(60000);
        //MetadataServer server2 = new MetadataServer(3,  "D:\\project-of-yang\\library\\config.xml", "D:\\project-of-yang\\library");
    }
}
